{{!
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
}}

{{breadcrumb-bar breadcrumbs=breadcrumbs}}

<div class="row container-fluid">

  <div class="col-md-12">
    <div class="row container-fluid">
      {{#if model.attempt}}
        <div class="panel panel-default">
          <div class="panel-body">
            <div class="flex">
              <div>
                <h3 class="top-2">{{model.attempt.id}}</h3>
                <div class="muted-text">{{model.attempt.appMasterContainerId}}</div>
                {{#if model.attempt.attemptState}}
                  {{em-table-simple-status-cell class="top-1" content=model.attempt.attemptState}}
                {{/if}}
                {{#if (or model.attempt.attemptStartedTime model.attempt.validatedFinishedTs)}}
                <div class="flex yarn-tooltip" title="Elapsed Time: {{model.attempt.elapsedTime}}">
                  {{#if model.attempt.attemptStartedTime}}
                  <div class="top-1 tail-2" >
                    <i class="glyphicon glyphicon-time glyphicon-gray" />
                    Started at {{model.attempt.attemptStartedTime}}
                  </div>
                  {{/if}}
                  {{#if model.attempt.validatedFinishedTs}}
                  <div class="top-1">
                    <i class="glyphicon glyphicon-time glyphicon-gray" />
                    Finished at {{model.attempt.validatedFinishedTs}}
                  </div>
                  {{/if}}
                </div>
                {{/if}}
              </div>
              <div class="flex-right">
                <div class="top-2">
                  <span>AM Host: </span>
                  <strong class="yarn-tooltip" title="{{model.attempt.amNodeId}}">{{model.attempt.amNodeId}}</strong>
                </div>
                {{#if model.attempt.nodeHttpAddress}}
                 <div class="top-1">
                  <span>AM Node WebUI: </span>
                  <strong class="yarn-tooltip" title="{{model.attempt.nodeHttpAddress}}">
                    <a href="{{model.attempt.masterNodeURL}}">{{model.attempt.nodeHttpAddress}}</a>
                  </strong>
                </div>
                {{/if}}
                {{#if model.attempt.logsLink}}
                <div class="top-1">
                  <span>Log: </span>
                  <strong>
                    <a href="{{prepend-protocol model.attempt.logsLink}}" target="_blank">{{model.attempt.logsLink}}</a>
                  </strong>
                </div>
                {{/if}}
              </div>
            </div>
            {{#if model.attempt.diagnosticsInfo}}
            <div class="panel panel-default top-3">
              <div class="panel-heading">
                Diagnostic Info for {{model.attempt.id}}
              </div>
              <div class="diagnostic-info">
                <pre>{{model.attempt.diagnosticsInfo}}</pre>
              </div>
            </div>
            {{/if}}
          </div>
        </div>
      {{/if}}
    </div>
    <div class="row">
      {{#if (or model.rmContainers model.tsContainers)}}
        {{timeline-view
          parent-id="containers-timeline-div"
          my-id="timeline-view"
          height="400"
          rmModel=model.rmContainers
          tsModel=model.tsContainers
          label="shortAppAttemptId"
          attemptModel=false
          changeViewType="changeViewType"
          viewType=viewType
        }}
      {{else}}
        <div class="col-md-12 container-fluid">
          <div class="panel panel-default">
            <div class="panel-heading">
               Containers
            </div>
            <div class="panel-body">
              <h4 class="text-center">No data available!</h4>
            </div>
          </div>
        </div>
      {{/if}}
    </div>
  </div>
</div>
